package voice;

import java.io.File;
import java.io.IOException;

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;

/**
 * Implements email message
 * @author Alexandre, Cristovao, Raul, Rodolpho, Tales
 * @version 1.1
 * @milestone Number 2
 */
public class Recorder extends Thread{
	
	AudioInputStream line;
	AudioFileFormat.Type targetType;
	File file;
	
	/**
	 * Records a new message
	 * @param line
	 * @param targetType
	 * @param file
	 */
	public Recorder(AudioInputStream line, AudioFileFormat.Type targetType,
			File file) {
		super();
		this.file = file;
		this.line = line;
		this.targetType = targetType;
	}
	
	
	/**
	 * Start the recording of the audiofile
	 */
	public void run(){
		try {
			AudioSystem.write(line, targetType, file);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
